package com.jiang.spring_security_singleboot.advice;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * @中软华腾软件系统有限公司,未经授权不得擅自传播
 * @类描述:
 * @类名称:ExceptionHanlderAdvice
 * @作者: 蒋正午
 * @编辑时间: 2021/4/27 11:21
 * @版本: 1.0
 */
@ControllerAdvice
public class ExceptionHanlderAdvice {

    @ExceptionHandler(Exception.class)
    public String exceptionHandler(Exception e){
        System.out.println(e);
        if(e instanceof AccessDeniedException){
            return "redirect:/403.jsp";
        }
        return "redirect:/500.jsp";
    }

}
